home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: Philippe Verdy <100105.3120@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Visual C++ Help Needed - Serialize/ar problem
- Date: 7 Apr 1996 21:32:50 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4k9ca2$fl9@arl-news-svc-5.compuserve.com>
- NNTP-Posting-Host: ad04-110.compuserve.com
-
- kirki@cts.com (kirk i.) s'Θcrit :
- > Hi...newbe to OOD and Visual C++ here. I created an object that initiates 3
- > edit boxes with the following intigers:
- >
- > int m_seed = 0;
- > int m_popsize = 0;
- > int m_seed10 = m_seed +10;
- >
- > all ...generally works well, in that the program window intiiates with the
- > values 0, 0, and 10...so, the next step was to use the Serialize
- > object/function to try to store and recall the three integer values after i
- > change them. so, i applied the following code:
- >
- > // CGene2Doc serialization
- >
- > void CGene2Doc::Serialize(CArchive& ar)
- > {
- > if (ar.IsStoring())
- > {
- > //itoa(m_seed, sSeed, 10);
- > //itoa(m_popsize, sPopsize, 10);
- > //itoa(m_seed, sSeed10, 10);
- >
- > ar << m_seed;
- > ar << m_popsize;
- > ar << m_seed10;
- > }
- > else
- > {
- > //ar >> sSeed;
- > //ar >> sPopsize;
- > //ar >> sSeed10;
- > //m_seed = atoi(const char *sSeed);
- > //m_popsize = atoi(sPopsize);
- > //m_seed10 = atoi(sSeed10);
- > }
- > }
- >
- > when i compile, i get:
- >
- > D:\Work\gene2\gene2doc.cpp
- > D:\Work\gene2\gene2doc.cpp(61) : error C2593: 'operator <<' is ambiguous
- > D:\Work\gene2\gene2doc.cpp(62) : error C2593: 'operator <<' is ambiguous
- > D:\Work\gene2\gene2doc.cpp(63) : error C2593: 'operator <<' is ambiguous
- >
- >
- > ...what did i do wrong here?
- >
- > thanks in advance,
- > kirk
- >
- I don't know Visual classes. But is CArchive your own class ?
- If so, did you define the << operators your self ?
- - If so, did you declare several << operators for different
- integer types ? If so did you forget the operator<<(int) ?
- - If not, what kind of << operators did you define ? If you
- defined several << operators for different classes X
- which have conversions "operator X(int)" or constructors
- "X::X(int)", may be they conflict because several conversions
- are possible ...
- Check you code and remove unnecessary conversions, or add
- an explicit CArchive::operator<<(const int) which will
- bypass any problematic conversions...
-
-